<?php

class Admin_Form_QuestionForm extends Zend_Form
{

    public function init()
    {
        $this->setMethod('post');
        $this->setAttrib('class', 'validate-form tab-add-question');
        
        $this->addElement('select','cbbMonHoc',array(
        					'label'			=>	'Mon học (*)',
        					'required'		=>	true,
        					'class'			=>	'required',
        					'multiOptions'	=>	$this->getMonHoc()
        				)
        		);
        $this->addElement('textarea','txtArName',array(
        					'label'		=>	'Câu hỏi (*)',
        					'required'	=>	true,
        					'class'		=>	'required tinyMceQues',
        					'id'		=>	'tinyMceQues',
        					'rows'		=>	4,
        					'cols'		=>	50
        				)
        		);
        
        if(isset($_REQUEST['cbbMonHoc'])){
        	//$this->getElement('cbbMonHoc')->set
        }
        
        $this->addElement('textarea','txtA',array(
        					'label'		=>	'Đáp án A',
        					'required'	=>	true,
        					'class'		=>	'required tinyMce',
        					'rows'		=>	3,
        					'cols'		=>	10,
        					'maxlenght'	=>	300
		        		)
		        );
        $this->addElement('textarea','txtB',array(
        					'label'		=>	'Đáp án B',
        					'required'	=>	true,
        					'class'		=>	'required tinyMce',
        					'rows'		=>	3,
        					'cols'		=>	10,
        					'maxlenght'	=>	300
		        		)
		        );
        $this->addElement('textarea','txtC',array(
        					'label'		=>	'Đáp án C',
        					'required'	=>	true,
        					'class'		=>	'required tinyMce',
        					'rows'		=>	3,
        					'cols'		=>	10,
        					'maxlenght'	=>	300
		        		)
		        );
        $this->addElement('textarea','txtD',array(
        					'label'		=>	'Đáp án D ',
        					'class'		=>	'tinyMce',
        					'rows'		=>	3,
        					'cols'		=>	10,
        					'maxlenght'	=>	300
		        		)
		        );
        $this->addElement('textarea','txtE',array(
        					'label'		=>	'Đáp án E',
        					'class'		=>	'tinyMce',
        					'rows'		=>	3,
        					'cols'		=>	10,
        					'maxlenght'	=>	300
		        		)
		        );
        $this->addElement('select','cbbTrueQuestion',array(
        					'label'			=>	'Đáp án đúng',
        					'required'		=>	true,
        					'class'			=>	'required',
        					'maxlength'		=>	1,
        					'multiOptions'	=>	array(
        										'a'	=>	'Đáp án A',
        										'b'	=>	'Đáp án B',
        										'c'	=>	'Đáp án C',
        										'd'	=>	'Đáp án D',
        										'e'	=>	'Đáp án E'
        									)
		        		)
		        );
        $this->addElement('select','cbbLevel',array(
        					'label'			=>	'Mức độ câu hỏi',
        					'required'		=>	true,
        					'class'			=>	'required',
       						'multiOptions'	=> array(
        										'de'		=>	'Dễ',
        										'trungBinh'	=>	'Trung bình',
        										'kho'		=>	'Khó'
        									)
		        		)
		        );
    }

 /**
     * 
     * Set action cho form
     * @param unknown_type $actionName: ten cua action
     */
    function addAction($actionName){
    	$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl()."/admin/question/".$actionName);
    }
    
    private function getMonHoc(){
    	$mon = new Admin_Model_Monhoc();
    	$data = array();
    	foreach ($mon->fetchAllMonHoc() as $value) {
    		$data[$value['id']] = $value['tenMonHoc'];
    	}
    	
    	return $data;
    }

	function addSubmitButton($name, $label){
    	$this->addElement('submit',$name,array(
    						'label'		=>	$label,
    						'decorators'=>	array('ViewHelper',array('HtmlTag',array(
    																			'tag' => 'dd' //giu nguyen the dd ko them bat cu the j
    																		)
    														
    															)
    							
    										),
    						'class'		=>	'input-hover uSubmit'	
    					));
    	
    }
    
    function addHiddenId($name,$value){
    	$this->addElement('hidden',$name,array(
			    				'value'	=> $value	
    						));
    }
}

